package dayPractice;


import java.util.Scanner;

/**
 * @author Summerday
 */
public class Main703数独 {

    static boolean[][] col = new boolean[9][9];
    static boolean[][] row = new boolean[9][9];
    static boolean[][][] sq = new boolean[3][3][9];
    static char[][] g = new char[9][9];
    static boolean flag;

    public static void main (String[] args) {

        Scanner sc = new Scanner(System.in);
        for(int i = 0; i < 9; i ++){
            g[i] = sc.next().toCharArray();
        }
        for(int i = 0; i< 9; i ++){
            for(int j = 0; j < 9; j ++){
                if(g[i][j] == '.') continue;
                int num = g[i][j] - '1';
                row[i][num] = col[j][num] = sq[i / 3][j  / 3][num] = true;
            }
        }
        dfs(0, 0);

    }

    static void dfs(int x, int y){
        if(flag) return;
        if(y == 9) {
            y = 0; x ++;
        }
        if(x == 9) {
            flag = true;
            for(char[] chs : g) System.out.println(String.valueOf(chs));
            return ;
        }
        if(g[x][y]!= '.') {
           dfs(x , y + 1);
           return;
        }
        for(int i = 0; i < 9; i ++){
            if(row[x][i] || col[y][i] || sq[x / 3][y / 3][i]) continue;

            g[x][y] = (char)(i + '1');
            row[x][i] = col[y][i] = sq[x / 3][y / 3][i] = true;
            dfs(x, y + 1);
            if(flag) return ;
            g[x][y] = '.';
            row[x][i] = col[y][i] = sq[x / 3][y / 3][i] = false;
        }
    }
}
